@extends('layouts.admin')
@push('morecss')
    <link href="{{ asset('/vendor/AdminInspinia/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css') }}"
          rel="stylesheet">
@endpush

@push('morescript')
    <script type="application/javascript">
        let page_params = {
            @can('admin.wxcard.index')
            url_list: '{{ route('admin.wxcard.index') }}',
            @endcan
                    @can('admin.wxcard.create')
            url_add: '{{ route('admin.wxcard.create') }}',
            @endcan
                    @can('admin.wxcard.update')
            url_edit: '{{ route('admin.wxcard.update') }}',
            @endcan
                    @can('admin.wxcard.destroy')
            url_del: '{{ route('admin.wxcard.destroy') }}',
            @endcan
                    @can('admin.wxcard.publish')
            url_publish: '{{ route('admin.wxcard.publish') }}',
            @endcan
                    @can('admin.wxcard.sync')
            url_sync: '{{ route('admin.wxcard.sync') }}',
            @endcan
                    @can('admin.wxcard.modifystock')
            url_modifystock: '{{ route('admin.wxcard.modifystock') }}',
            @endcan
                    @can('admin.wxcard.upsettestwhite')
            url_upsettestwhite: '{{ route('admin.wxcard.upsettestwhite') }}',
            @endcan
            data_card_type:@json($cardTypeList),
        }
    </script>
    <!-- require page js -->
    <script src="{{ mix('js/admin/wxcard_index.js') }}"></script>
@endpush
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight ecommerce">
        <div class="ibox-content m-b-sm border-bottom">
            <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="control-label" for="keyword">卡券类型</label>
                        <select class="form-control" name="card_type"
                                v-model="searchParams.card_type">
                            <option value="">请选择卡券类型</option>
                            <option v-for="item in card_type_list" v-bind:value="item.type">
                                @{{ item.name }}
                            </option>
                        </select>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="control-label" for="keyword">关键字</label>
                        <input type="text" id="keyword" name="keyword" v-model="searchParams.keyword"
                               placeholder="请输入搜索关键字"
                               class="form-control">
                    </div>
                </div>
                <div class="col-sm-2">
                    <div class="form-group">
                        <label class="control-label" for="product_name">&nbsp;&nbsp;</label>
                        <div>
                            <button class="btn btn-primary" type="button" v-on:click="query"><i
                                        class="fa fa-search"></i>
                                搜索
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="toolbar" class="col-sm-5" style="width: 500px;">
            @can('admin.wxcard.create')
                <a class="btn btn-primary" href="{{ route('admin.wxcard.create') }}"><i class="fa fa-plus"></i> 添加卡券</a>
            @endcan
            @can('admin.wxcard.upsettestwhite')
                <button class="btn btn-primary" type="button" v-on:click="openTestWhite"><i class="fa fa-cog"></i>
                    设置测试白名单
                </button>
            @endcan
            @can('admin.wxcard.sync')
                <button class="btn btn-primary" v-on:click="sync" type="button" id="btn-sync"><i class="fa fa-cloud-download"></i>
                    拉取微信端卡券
                </button>
            @endcan
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <table id="table" data-classes="table table-no-bordered">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 卡券测试白名单设置 -->
    <div class="ibox-content" id="box-testwhite" style="display: none">
        <form class="form-horizontal m-t" method="post" action="">
            <div class="form-group">
                <label class="col-sm-3 control-label">白名单列表：</label>
                <div class="input-group col-sm-7">
                    <input-tag :tags.sync="testWhiteData.openIds" placeholder="请输入用户openId..."></input-tag>
                    <span class="help-block m-b-none">按回车键确认openId,最多设置10个</span>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4">
                    <button class="btn btn-primary btn-sub" type="button" v-on:click="saveTestWhite">提交</button>
                </div>
            </div>
        </form>
    </div>
    <!--卡券库存设置-->
    <div class="ibox-content" id="box-modifystock" style="display: none">
        <form class="form-horizontal m-t" method="post" action="">
            <div class="form-group">
                <label class="col-sm-4 control-label">操作类别：</label>
                <div class="input-group col-sm-8">
                    <div class="radio radio-primary radio-inline">
                        <input type="radio" id="modType1" value="increase"
                               name="mod_type"
                               v-model="stockModData.mod_type">
                        <label for="modType1"> 增加库存 </label>
                    </div>
                    <div class="radio radio-primary radio-inline">
                        <input type="radio" id="modType2"
                               value="reduce" name="mod_type"
                               v-model="stockModData.mod_type">
                        <label for="modType2"> 减少库存 </label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">数量</label>
                <div class="col-sm-8">
                    <input type="number" class="form-control" min="1" step="1"
                           v-model="stockModData.stock_num">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4">
                    <button class="btn btn-primary btn-sub" type="button" v-on:click="saveModStock">提交</button>
                </div>
            </div>
        </form>
    </div>
@endsection